<template>
	<view>
		<linke-ux-editor v-model="content" :cloud="false" :url="url"></linke-ux-editor>
		<button type="primary" style="margin: 0 10px;" @click="save">保存</button>
		<button type="success" style="margin: 20rpx 10px;" @click="preview">保存并预览</button>
	</view>
</template>

<script>
import uxEditor from '../../../uni_modules/linke-ux-editor/static/js/editor.js';

export default {
	data() {
		return {
			content: [],
			 // 上传文件的URL，如 'https://a.com/oss/upload',
			 // 返回数据 { data: '文件地址'}，注意格式一定要正确
			url: 'http://192.168.4.243:801/file.php',
			// 是否启用 uniCloud上传，url 二选一，详细看文档说明
			cloud: false
		};
	},
	props: {},
	methods: {
		save() {
			console.log('save#', this.content);
			uni.setStorageSync('ux_content', JSON.stringify(this.content));
		},
		preview() {
			this.save();
			console.log('yulan');
			uni.navigateTo({
				url: '/pages/template/ux-editor/detail'
			});
		}
	},
	onShow() {
		let d = uni.getStorageSync('ux_content');
		if(d){
			this.content = JSON.parse(d);
		}
		// uxEditor.tempDataHandler(this.content);
	}
};
</script>

<style lang="scss"></style>
